﻿using System;
using System.Linq;
using Landpy.CruiseControlNet.FacadeInterface.ConfigurationModule;
using Landpy.CruiseControlNet.FacadeInterface.RepositoryModule;
using Landpy.CruiseControlNet.Infrastructure.Aop.WrapAttribute;

namespace Landpy.CruiseControlNet.DomainLayer.RepositoryModule
{
    public class ProjectRepository : IProjectRepository
    {
        [NotThrowException]
        [ExceptionMessageBox]
        [LogException]
        public Project GetProjectById(CruiseControl cruiseControl, Guid id)
        {
            var queryProject = (from Project project in cruiseControl.Projects
                                where project.Id == id
                                select project).FirstOrDefault();
            return queryProject;
        }

        [NotThrowException]
        [ExceptionMessageBox]
        [LogException]
        public Project GetProjectByName(CruiseControl cruiseControl, string name)
        {
            var queryProject = (from Project project in cruiseControl.Projects
                                where project.Name == name
                                select project).FirstOrDefault();
            return queryProject;
        }
    }
}
